package com.google.android.gms.internal;

import com.google.android.gms.internal.zzdva;
import com.google.android.gms.internal.zzfhu;
import java.io.IOException;

public final class zzduy extends zzfhu<zzduy, zza> implements zzfje {
    private static volatile zzfjl<zzduy> zzbbm;
    /* access modifiers changed from: private */
    public static final zzduy zzmgi;
    private int zzmgc;
    private zzdva zzmgg;

    public static final class zza extends zzfhu.zza<zzduy, zza> implements zzfje {
        private zza() {
            super(zzduy.zzmgi);
        }

        /* synthetic */ zza(zzduz zzduz) {
            this();
        }
    }

    static {
        zzduy zzduy = new zzduy();
        zzmgi = zzduy;
        zzduy.zza(zzfhu.zzg.zzppw, (Object) null, (Object) null);
        zzduy.zzpph.zzbkr();
    }

    private zzduy() {
    }

    public static zzduy zzq(zzfgs zzfgs) throws zzfie {
        return (zzduy) zzfhu.zza(zzmgi, zzfgs);
    }

    public final int getKeySize() {
        return this.zzmgc;
    }

    /* access modifiers changed from: protected */
    public final Object zza(int i, Object obj, Object obj2) {
        zzdva.zza zza2;
        boolean z = false;
        switch (zzduz.zzbbk[i - 1]) {
            case 1:
                return new zzduy();
            case 2:
                return zzmgi;
            case 3:
                return null;
            case 4:
                return new zza((zzduz) null);
            case 5:
                zzfhu.zzh zzh = (zzfhu.zzh) obj;
                zzduy zzduy = (zzduy) obj2;
                this.zzmgg = (zzdva) zzh.zza(this.zzmgg, zzduy.zzmgg);
                boolean z2 = this.zzmgc != 0;
                int i2 = this.zzmgc;
                if (zzduy.zzmgc != 0) {
                    z = true;
                }
                this.zzmgc = zzh.zza(z2, i2, z, zzduy.zzmgc);
                return this;
            case 6:
                zzfhb zzfhb = (zzfhb) obj;
                zzfhm zzfhm = (zzfhm) obj2;
                if (zzfhm != null) {
                    while (!z) {
                        try {
                            int zzcxx = zzfhb.zzcxx();
                            if (zzcxx != 0) {
                                if (zzcxx == 10) {
                                    if (this.zzmgg != null) {
                                        zzdva zzdva = this.zzmgg;
                                        zzfhu.zza zza3 = (zzfhu.zza) zzdva.zza(zzfhu.zzg.zzppy, (Object) null, (Object) null);
                                        zza3.zza(zzdva);
                                        zza2 = (zzdva.zza) zza3;
                                    } else {
                                        zza2 = null;
                                    }
                                    this.zzmgg = (zzdva) zzfhb.zza(zzdva.zzbpg(), zzfhm);
                                    if (zza2 != null) {
                                        zza2.zza(this.zzmgg);
                                        this.zzmgg = (zzdva) zza2.zzczw();
                                    }
                                } else if (zzcxx == 16) {
                                    this.zzmgc = zzfhb.zzcyg();
                                } else if (!zza(zzcxx, zzfhb)) {
                                }
                            }
                            z = true;
                        } catch (zzfie e) {
                            throw new RuntimeException(e.zzi(this));
                        } catch (IOException e2) {
                            throw new RuntimeException(new zzfie(e2.getMessage()).zzi(this));
                        }
                    }
                    break;
                } else {
                    throw new NullPointerException();
                }
            case 7:
                break;
            case 8:
                if (zzbbm == null) {
                    synchronized (zzduy.class) {
                        if (zzbbm == null) {
                            zzbbm = new zzfhu.zzb(zzmgi);
                        }
                    }
                }
                return zzbbm;
            case 9:
                return (byte) 1;
            case 10:
                return null;
            default:
                throw new UnsupportedOperationException();
        }
        return zzmgi;
    }

    public final void zza(zzfhg zzfhg) throws IOException {
        if (this.zzmgg != null) {
            zzfhg.zza(1, (zzfjc) this.zzmgg == null ? zzdva.zzbpg() : this.zzmgg);
        }
        if (this.zzmgc != 0) {
            zzfhg.zzae(2, this.zzmgc);
        }
        this.zzpph.zza(zzfhg);
    }

    public final zzdva zzbpc() {
        return this.zzmgg == null ? zzdva.zzbpg() : this.zzmgg;
    }

    public final int zzhs() {
        int i = this.zzppi;
        if (i != -1) {
            return i;
        }
        int i2 = 0;
        if (this.zzmgg != null) {
            i2 = 0 + zzfhg.zzc(1, (zzfjc) this.zzmgg == null ? zzdva.zzbpg() : this.zzmgg);
        }
        if (this.zzmgc != 0) {
            i2 += zzfhg.zzah(2, this.zzmgc);
        }
        int zzhs = i2 + this.zzpph.zzhs();
        this.zzppi = zzhs;
        return zzhs;
    }
}
